package com.swt.controller;

import com.swt.common.vo.ResponseVo;
import com.swt.domain.Permission;
import com.swt.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/17
 */
@RestController
@RequestMapping("/Permission")
public class PermissionController {
    @Autowired
    public PermissionService permissionService;
    @GetMapping("/{count}/{size}")
    public ResponseVo pagePermission(@PathVariable Integer count, @PathVariable Integer size){
        return ResponseVo.SUCCESS(permissionService.pagePermission(count,size));

    }
    @DeleteMapping("/{id}")
    public ResponseVo deletePermission(@PathVariable String id){
        return permissionService.delectPermission(id)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @GetMapping("/{id}")
    public ResponseVo selectPermissionById(@PathVariable String id){
        return ResponseVo.SUCCESS(permissionService.selectbyPermission(id));
    }
    @PostMapping
    public ResponseVo insertPermission(@RequestBody Permission s){
        return permissionService.inserPermission(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PutMapping
    public ResponseVo updatePermission(@RequestBody Permission s){
        return permissionService.updatePermission(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
}

